home *** CD-ROM | disk | FTP | other *** search
- class classes.enemy.DroidA2
- {
- var x;
- var y;
- var moveScript;
- var id;
- var clip;
- var matrixVar;
- var dir;
- var f2;
- var axis;
- var matrixCoords;
- var xDest;
- var yDest;
- var form;
- var advanceMax2;
- var advanceMax;
- var oldDir;
- var xMov = 0;
- var yMov = 0;
- var xmt = 0;
- var ymt = 0;
- var xMovT = 0;
- var yMovT = 0;
- var speedOrig = 8;
- var speed = 8;
- var xDestMet = false;
- var yDestMet = false;
- var c = 0;
- var feelerInfo = [[-400,0,400,40],[0,0,400,40],[0,-400,40,400],[0,0,40,400]];
- var dirArray = ["L","R","U","D"];
- var power = 15;
- var bg = false;
- var Name = "droidA2";
- function DroidA2(px, py, pmoveScript, pbg, pid)
- {
- this.x = px;
- this.y = py;
- this.moveScript = pmoveScript.slice();
- var _loc6_ = pbg.slice();
- this.bg = _loc6_[0];
- this.id = pid;
- _root.d = _root.d + 1;
- this.clip = _root.attachMovie("droidA","droidA2" + this.id + "Clip",_root.d + 50000);
- this.clip._x = this.x;
- this.clip._y = this.y;
- this.speedVar();
- var _loc4_ = new flash.geom.Transform(this.clip);
- if(!this.bg)
- {
- var _loc3_ = _root.randRange(-20,20);
- var _loc5_ = new flash.geom.ColorTransform(1,1,1,1,_loc3_,_loc3_,_loc3_,0);
- _loc4_.colorTransform = _loc5_;
- }
- else
- {
- _loc5_ = new flash.geom.ColorTransform(1,1,1,1,-80,-80,-60,0);
- _loc4_.colorTransform = _loc5_;
- this.clip._xscale = 66;
- this.clip._yscale = 66;
- this.speed *= 0.66;
- }
- this.parseMoveScript();
- }
- function broBehind()
- {
- this.matrixVar = 0;
- this.yMovT = 0;
- if(random(3) == 1)
- {
- var _loc3_ = _root.randRange2(1.2,1.4);
- this.xMovT = this.dir != "L" ? _loc3_ * this.speed : -1 * _loc3_ * this.speed;
- this.clip.body.gotoAndPlay("attack");
- this.clip.body.face.gotoAndPlay("attack");
- this.clip.body.flame.gotoAndPlay("start");
- this.f2 = "attacking";
- }
- else
- {
- this[this.axis + "MovT"] = 0;
- this.axis = random(2) <= 0 ? "x" : "y";
- _loc3_ = _root.randRange2(0.9,1.1);
- this[this.axis + "MovT"] = random(2) <= 0 ? -1 * _loc3_ * this.speed : _loc3_ * this.speed;
- this.getDirString();
- this.clip.body.flame.gotoAndPlay("start");
- this.f2 = "wander";
- }
- }
- function speedVar()
- {
- if(random(3) == 1)
- {
- this.speed *= _root.randRange2(0.9999,1.0001);
- }
- }
- function bombed(num)
- {
- this.f2 = "death";
- }
- function parseMoveScript()
- {
- this.dir = this.moveScript[0];
- if(this.dir == "break")
- {
- delete this.moveScript;
- this[this.axis + "MovT"] = 0;
- if(this.matrixCoords[0] == "free")
- {
- this.f2 = "wander";
- this.axis = random(10) <= 4 ? "y" : "x";
- this[this.axis + "MovT"] = random(2) <= 0 ? -1 * this.speed : this.speed;
- this.speedVar();
- this.getDirString();
- }
- else
- {
- this.xDest = _root.advanceDir != "L" ? this.matrixCoords[0] * 60 : this.matrixCoords[0] * 60 + 320;
- this.yDest = this.matrixCoords[1] * 50 + 10;
- this.axis = Math.abs(this.xDest - this.x) <= Math.abs(this.yDest - this.y) ? "y" : "x";
- this[this.axis + "MovT"] = this[this.axis + "Dest"] <= this[this.axis] ? -1 * this.speed : this.speed;
- this.getDirString();
- this.speedVar();
- this.f2 = "gotoMatrix";
- }
- }
- else
- {
- this[this.axis + "MovT"] = 0;
- this.f2 = "gotoXYDest";
- this.axis = !(this.dir == "L" || this.dir == "R") ? "y" : "x";
- this[this.axis + "MovT"] = !(this.dir == "L" || this.dir == "U") ? this.speed : -1 * this.speed;
- this.speedVar();
- if(this.dir == "L" || this.dir == "U")
- {
- this[this.axis + "Dest"] = this[this.axis] - this.moveScript[1];
- }
- else
- {
- this[this.axis + "Dest"] = this[this.axis] + this.moveScript[1];
- }
- this.moveScript.splice(0,2);
- }
- }
- function gotoXYDest()
- {
- if(Math.abs(this[this.axis + "Dest"] - this[this.axis]) < this.speed + 1)
- {
- if(this.axis == "x")
- {
- this.x = this.xDest;
- }
- else
- {
- this.y = this.yDest;
- }
- this.parseMoveScript();
- }
- }
- function gotoMatrix()
- {
- if(Math.abs(this[this.axis + "Dest"] - this[this.axis]) < this.speed + 1)
- {
- if(this.axis == "x")
- {
- this.x = this.xDest;
- }
- else
- {
- this.y = this.yDest;
- }
- this[this.axis + "MovT"] = 0;
- this.axis = this.axis != "x" ? "x" : "y";
- this[this.axis + "MovT"] = this[this.axis + "Dest"] <= this[this.axis] ? -1 * this.speed : this.speed;
- this.getDirString();
- this.speed = this.speedOrig;
- }
- if(Math.abs(this.x - this.xDest) < this.speed + 1 && Math.abs(this.y - this.yDest) < this.speed + 1)
- {
- this.x = this.clip._x = this.xDest;
- this.y = this.clip._y = this.yDest;
- this.xMovT = this.xMov = 0;
- this.yMovT = this.yMov = 0;
- this.matrixVar = 2;
- this.dir = _root.advanceDir;
- this.clip.body.flame.gotoAndPlay("still");
- _root.matrixNum = _root.matrixNum + 1;
- if(_root.matrixNum >= _root.matrixSize)
- {
- _root.matrixComplete = true;
- }
- _root["formB" + this.form[0]] = "matrixed";
- this.f2 = "wait";
- }
- }
- function getDirString()
- {
- if(this.xMovT < -1)
- {
- this.dir = "L";
- }
- else if(this.xMovT > 1)
- {
- this.dir = "R";
- }
- else if(this.yMovT > 1)
- {
- this.dir = "D";
- }
- else if(this.yMovT < -1)
- {
- this.dir = "U";
- }
- }
- function wait()
- {
- if(random(1000) >= 998 && _root.matrixComplete)
- {
- this.dir = this.findDir();
- if(this.dir == _root.advanceDir)
- {
- this.xMovT = _root.advanceDir != "L" ? 1.3 * this.speed : -1.3 * this.speed;
- this.clip.body.gotoAndPlay("attack");
- this.clip.body.face.gotoAndPlay("attack");
- this.clip.body.flame.gotoAndPlay("start");
- this.f2 = "attacking";
- this.matrixVar = 0;
- }
- else if(this.dir == "U" || this.dir == "D")
- {
- this.axis = !(this.dir == "L" || this.dir == "R") ? "y" : "x";
- this[this.axis + "MovT"] = !(this.dir == "L" || this.dir == "U") ? this.speed : -1 * this.speed;
- this.matrixVar = 0;
- this.c = 0;
- this.f2 = "leavingMatrix";
- this.clip.body.flame.gotoAndPlay("start");
- }
- else
- {
- this.dir = _root.advanceDir;
- }
- }
- }
- function leavingMatrix()
- {
- this.c = this.c + 1;
- if(this.c > this.advanceMax2)
- {
- this.c = 0;
- this.dir = this.findDir();
- if(this.dir == _root.advanceDir)
- {
- this.yMovT = 0;
- this.xMovT = _root.advanceDir != "L" ? 1.3 * this.speed : -1.3 * this.speed;
- this.clip.body.gotoAndPlay("attack");
- this.clip.body.face.gotoAndPlay("attack");
- this.f2 = "attacking";
- }
- }
- }
- function findDir()
- {
- _root.d = _root.d + 1;
- _root.attachMovie("feeler","feelerClip",_root.d);
- var _loc7_ = [];
- var _loc9_ = 0;
- var _loc11_ = this.dirArray.length;
- while(_loc9_ < _loc11_)
- {
- _root.feelerClip._x = this.x + this.feelerInfo[_loc9_][0];
- _root.feelerClip._y = this.y + this.feelerInfo[_loc9_][1];
- _root.feelerClip._width = this.feelerInfo[_loc9_][2];
- _root.feelerClip._height = this.feelerInfo[_loc9_][3];
- var _loc3_ = 0;
- var _loc8_ = _root.chars.length;
- var _loc6_ = false;
- while(_loc3_ < _loc8_)
- {
- var _loc5_ = _root.chars[_loc3_] + "Clip";
- if(_root.feelerClip.hitTest(_root[_loc5_]))
- {
- var _loc4_ = _root.chars[_loc3_];
- if(_root[_loc4_].matrixVar == 2 && _loc4_ != this.Name + this.id)
- {
- _loc6_ = true;
- break;
- }
- }
- _loc3_ = _loc3_ + 1;
- }
- if(!_loc6_)
- {
- var _loc10_ = _root.advanceDir != "L" ? "L" : "R";
- if(this.dirArray[_loc9_] != _loc10_)
- {
- _loc7_.push(this.dirArray[_loc9_]);
- }
- }
- _loc9_ = _loc9_ + 1;
- }
- _loc9_ = 0;
- _loc11_ = _loc7_.length;
- if(_loc9_ < _loc11_)
- {
- if(_loc7_[_loc9_] == _root.advanceDir)
- {
- return _root.advanceDir;
- }
- return _loc7_[random(_loc7_.length)];
- }
- }
- function attacking()
- {
- }
- function death()
- {
- if(this.matrixVar == 1)
- {
- _root.matrixNum = _root.matrixNum + 1;
- if(_root.matrixNum >= _root.matrixSize)
- {
- _root.matrixComplete = true;
- }
- }
- _root.powerUp(this.x,this.y,96);
- var _loc3_ = 0;
- var _loc4_ = _root["form" + this.form[0]].length;
- while(_loc3_ < _loc4_)
- {
- if(_root["form" + this.form[0]][_loc3_] == "droidA2" + this.id)
- {
- _root["form" + this.form[0]].splice(_loc3_,1);
- if(_root["form" + this.form[0]].length == 0)
- {
- delete _root["form" + this.form[0]];
- if(_root["formB" + this.form[0]] == "matrixed")
- {
- _root.createPowerUp([this.x,this.y,"coin1"]);
- }
- else
- {
- _root.createPowerUp([this.x,this.y,"coin1"]);
- }
- delete _root["formB" + this.form[0]];
- }
- break;
- }
- _loc3_ = _loc3_ + 1;
- }
- _root.createExploA([this.x + this.clip._width / 2,this.y + this.clip._height / 2,_root.randRange(80,130),_root.randRange(75,100)]);
- _loc3_ = 0;
- _loc4_ = random(3);
- while(_loc3_ < _loc4_)
- {
- _root.createShrapnel([this.x + this.clip._width / 2,this.y + this.clip._height / 2,"droidA2"]);
- _loc3_ = _loc3_ + 1;
- }
- _root.createDroidA2Soul([this.x + this.clip._width / 2,this.y + this.clip._height / 2]);
- _root.removeChar("droidA2" + this.id);
- this.f2 = "";
- }
- function advance()
- {
- this.dir = _root.advanceDir;
- this.clip.body.flame.gotoAndPlay("advance");
- this.xMovT = _root.advanceDir != "L" ? 1 * (this.speed / 2) : -1 * (this.speed / 2);
- this.f2 = "advancing";
- }
- function advancing()
- {
- this.c = this.c + 1;
- if(this.c > this.advanceMax)
- {
- this.xMovT = 0;
- this.c = 0;
- this.f2 = "wait";
- _root.d = _root.d + 1;
- _root.attachMovie("sight","sightClip",_root.d);
- _root.sightClip.gotoAndStop("hindSight");
- _root.sightClip._x = this.x;
- _root.sightClip._y = this.y;
- if(_root.advanceDir == "L")
- {
- _root.sightClip._rotation = 180;
- }
- if(_root.sightClip.hitTest(_root[_root.char].x,_root[_root.char].y,true))
- {
- _root.broBehind();
- }
- removeMovieClip(_root.sightClip);
- }
- }
- function wander()
- {
- if(random(100) > 98)
- {
- this[this.axis + "MovT"] = 0;
- this.axis = this.axis != "x" ? "x" : "y";
- this[this.axis + "MovT"] = random(2) <= 0 ? -1 * this.speed : this.speed;
- this.getDirString();
- }
- }
- function death2()
- {
- _root.removeChar("droidA2" + this.id);
- this.f2 = "";
- }
- function main()
- {
- this[this.f2]();
- if(this.oldDir != this.dir)
- {
- this.clip.gotoAndStop("fly" + this.dir);
- }
- this.oldDir = this.dir;
- if(this.x > 1050 || this.x < -50 || this.y < -50 || this.y > 650)
- {
- delete _root["form" + this.form[0]];
- delete _root["formB" + this.form[0]];
- this.f2 = "death2";
- }
- if(this.xMovT < this.xMov)
- {
- this.xMov -= 1;
- }
- else if(this.xMovT > this.xMov)
- {
- this.xMov += 1;
- }
- else
- {
- this.xMov = this.xMovT;
- }
- if(this.yMovT < this.yMov)
- {
- this.yMov -= 1;
- }
- else if(this.yMovT > this.yMov)
- {
- this.yMov += 1;
- }
- else
- {
- this.yMov = this.yMovT;
- }
- this.xmt = this.xMov;
- this.ymt = this.yMov;
- if(random(10) == 1)
- {
- if(this.axis == "y")
- {
- this.xmt += _root.randRange2(-1,1);
- }
- else
- {
- this.ymt += _root.randRange2(-1,1);
- }
- }
- this.x += this.xmt;
- this.y += this.ymt;
- this.clip._x = this.x;
- this.clip._y = this.y;
- }
- }
-